#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author:lxl

import tkinter as tk  # 使用Tkinter前需要先导入
import tkinter.messagebox  # 要使用messagebox先要导入模块

window = tk.Tk()
window.title("ListBox")
window.geometry("500x300")

var = tk.StringVar();

label = tk.Label(window, text="label", font=('Arial', 12), width=10, textvariable=var)
label.pack()


def print_selection():
    value = listBox.get(listBox.curselection())
    print(value)
    var.set(value)


btn = tk.Button(window, text="print selection", command=print_selection)
btn.pack()

listBox = tk.Listbox(window);

list_items = [11, 22, 33, 44]

for item in list_items:
    listBox.insert("end", item)

listBox.pack();

window.mainloop()
